import request from '@/utils/request'

/**
 * @param {*} data
 * 附件上传 file module module_id
 */
export const FileSaveUrl = 'setting/upload'

export function crmFileSave(data) {
	var param = new FormData()
	Object.keys(data).forEach(key => {
		param.append(key, data[key])
	})
	return request({
		url: 'setting/upload',
		method: 'post',
		data: param,
		headers: {
			'Content-Type': 'multipart/form-data'
		}
	})
}

// 附件删除
export function crmFileDelete(data) {
	return request({
		url: 'setting/delfile',
		method: 'post',
		data: data
	})
}


export function usersList(data) {
	return request({
		url: 'user/getUserList',
		method: 'post',
		data: data
	})
}

// 部门列表
export function depList(data) {
  return request({
    url: 'structures/index',
    method: 'post',
    data: data
  })
}

// 权限数据返回
export function adminIndexAuthList(data) {
	return request({
		url: 'user/authList',
		method: 'post',
		data: data
	})
}

// 用户重置密码
export function userResetPassword(data) {
	return request({
		url: 'setting/setpassword',
		method: 'post',
		data: data
	})
}

/**
 * 已读更新通知
 * @param {*} data
 */
export function readUpdateNoticeAPI(data) {
  return request({
    url: 'user/readNotice',
    method: 'post',
    data: data
  })
}

/**
 * 未读消息数
 * @param {*} data
 */
export function systemMessageUnreadCountAPI(data) {
  return request({
    url: 'user/getmessage',
    method: 'post',
    data: data
  })
}


/**
 * 系统消息列表
 * label 1 调解 2 诉讼
 * isRead 0 未读 1 已读
 * @param {*} data
 */
export function systemMessageListAPI(data) {
  return request({
    url: 'user/messageList',
    method: 'post',
    data: data
  })
}

/**
 * 读全部消息
 * @param {*} data
 */
export function systemMessageReadAllAPI(data) {
  return request({
    url: 'user/readAllMessage',
    method: 'post',
    data: data
  })
}

/**
 * 读消息
 * @param {*} data
 */
export function systemMessageReadAPI(data) {
  return request({
    url: 'user/updateMessage',
    method: 'post',
    data: data
  })
}

/**
 * 系统消息删除
 * @param {*} data
 */
export function systemMessageDeleteByIdAPI(data) {
  return request({
    url: `user/deletemessage`,
    method: 'post',
    data
  })
}


/**
 * 系统消息按类别删除
 * @param {*} data
 */
export function systemMessageClearAPI(data) {
  return request({
    url: 'user/clearmessage',
    method: 'post',
    data: data
  })
}